package de.thw.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import de.thw.web.service.WebsiteService;
import de.thw.web.model.Website;

@Controller
@RequestMapping("site/")
public class WebsiteController {

	@Autowired
	private WebsiteService serviceWebsite;

	// /////////////////////////////////////////////////////////////////////////////

	@RequestMapping("index")
	public String listContacts(Map<String, Object> map) {

		map.put("site", new Website());
		map.put("siteList", this.serviceWebsite.getAll());

		return "site";
	}

	@RequestMapping("home")
	public String home(Map<String, Object> map) {

		Website site1 = new Website();
		Website site2 = new Website();
		site1.setName("Seite 1");
		site2.setName("Seite 2");
		site1.setActive(true);
		site2.setActive(true);

		this.serviceWebsite.save(site1);
		this.serviceWebsite.save(site2);

		map.put("site", new Website());
		map.put("siteList", this.serviceWebsite.getAll());

		return "site";
	}

};